package com.wuhunyu.controller;


import com.wuhunyu.commonutils.query.CommonQuery;
import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.query.OrderQuery;
import com.wuhunyu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author wuhunyu
 * @since 2021-01-26
 */
@RestController
@RequestMapping("/order")
//@CrossOrigin
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PutMapping("/createOrder/{courseId}")
    public CommonResult createOrder(@PathVariable("courseId") String courseId, HttpServletRequest request) {
        return orderService.createOrder(courseId, request);
    }

    @PostMapping("/selectOrderInfo/{orderNo}")
    public CommonResult selectOrderInfo(@PathVariable("orderNo") String orderNo) {
        return orderService.selectOrderInfo(orderNo);
    }

    @PostMapping("/selectOrderStatus/{courseId}")
    public CommonResult selectOrderStatus(@PathVariable("courseId") String courseId, HttpServletRequest request) {
        return orderService.selectOrderStatus(courseId, request);
    }

    @PostMapping("/selectOrderStatus")
    public CommonResult selectOrderStatus(@RequestParam("courseId") String courseId, @RequestParam("memberId") String memberId) {
        return orderService.selectOrderStatus(courseId, memberId);
    }

    @PostMapping("/selectCourseOrder")
    public CommonResult selectCourseOrder(@RequestBody(required = false) OrderQuery orderQuery) {
        return orderService.selectCourseOrder(orderQuery);
    }

}

